# Maintainer(Arch): Felix Yan <felixonmars@archlinux.org>
# Contributor: Cedric Girard <girard.cedric@gmail.com>
# Maintainer: Sagar Acharya <sagar@hyperbola.info>

pkgname=proxychains-ng
pkgver=4.14
pkgrel=1
pkgdesc="A hook preloader that allows to redirect TCP traffic of existing dynamically linked programs through one or more SOCKS or HTTP proxies"
arch=('x86_64')
url="https://github.com/rofl0r/proxychains-ng"
license=('GPL-2')
provides=('proxychains')
replaces=('proxychains')
conflicts=('proxychains')
depends=('glibc')
makedepends=('quilt')
backup=('etc/proxychains.conf')
source=("http://ftp.barfooze.de/pub/sabotage/tarballs/$pkgname-$pkgver.tar.xz"
		"series"
		"0001-Use-proper-library-version-for-libproxychains.patch"
		"0002-Install-conffile-as-proxychains4.conf.patch")
sha512sums=('75a1a4629d2b7ebac9b909a694b395339cf669fa4e23bfcc57938e46377b5619f31c9651d2bc457d1ad10ec1be7747981106392bf8bf65999cb7bb9c748d7e95'
			'2cb27314579b099aa87ea02926838064bc61965ff75e6c3dd5d6e0a01a1f1e2f7eb2b4ea46cc9ba877c6eb1568cc17722390e60dfb0985e2b257aaec1a75ee84'
			'e52c9a5db04ed3e9281b40fcedb902a0a0a6d3cea28a7e4236a33e08a0002002066052e0699ad4978b808c352d6fd81df98c1063688a0b9bc4061319e3c2c719'
			'b0ab1a62a9e3a4d5750d7a7bc40181db070052481b055b088ce1849ca0c51b0ab203ca3c2cd5edf7c69317911daab46edbc1bb177d0f16065b2d54f11a642aa6')

prepare() {
	cd $pkgname-$pkgver

	mkdir ./patches
  	cp ${srcdir}/series ./patches
  	cp ${srcdir}/*.patch ./patches

  	export QUILT_PATCHES=patches
 	export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  	export QUILT_DIFF_ARGS='--no-timestamps'

  	quilt push -av
}

build() {
	cd $pkgname-$pkgver
	./configure --prefix=/usr --sysconfdir=/etc
	make
}

package() {
	cd $pkgname-$pkgver
	make DESTDIR="$pkgdir/" install install-config
	ln -s proxychains4 "$pkgdir/usr/bin/proxychains"
	install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/
}
